﻿Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.IO
Imports DotNetNuke
Namespace NVPortal.Modules.NVNews.Search

    Public MustInherit Class inc_ResultByDate
        Inherits Entities.Modules.PortalModuleBase
        Private day As Date
        Private catid As Integer
        Public CategoryName As String = "Tin tức"
        Private PageIndex As Integer = 1

#Region "Event Handlers"
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                If Not IsPostBack Then
                    If IsNumeric(Request.Item("pn")) Then
                        PageIndex = Request.Item("pn")
                    End If

                    'Response.Write("Search hehe!")
                    If IsDate(Request.Item("day")) Then
                        day = Request.Item("day")
                        'load data
                        LoadData()
                    End If
                End If
            Catch ex As Exception
                ProcessModuleLoadException(Me, ex)
            End Try

        End Sub
#End Region

        Public Sub LoadData()
            Dim ctlNews As New NV_NewsController
            Dim arr As ArrayList
            arr = ctlNews.NV_News_FindContent(2, PortalId, day, day, "", CInt(Request.Item("catid")))
            'Response.Write(arr.Count)
            Me.drgNews.DataSource = arr
            Me.drgNews.PageSize = 10
            Me.drgNews.CurrentPageIndex = PageIndex - 1
            Me.drgNews.DataBind()

            Me.ctlPaging.RowCount = arr.Count
            Me.ctlPaging.PageIndex = PageIndex
            Me.ctlPaging.PageSize = 10
            Me.ctlPaging.BindDataPaging()
        End Sub

        Public Function FormatURL(ByVal sitem As String, ByVal strID As String, ByVal scat As String, ByVal strCatID As String) As String
            Return NavigateURL() & "/" & scat & "/" & strCatID & "/" & sitem & "/" & strID & "/musvn.aspx"
        End Function


    End Class

End Namespace
